package com.azt.provider.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.azt.api.pojo.ProCategoryAttribute;
import com.azt.api.service.ProCategoryAttributeService;
import com.azt.provider.mapper.ProCategoryAttributeMapper;

@Service
@Transactional
public class ProCategoryAttributeServiceImpl implements ProCategoryAttributeService{

	@Autowired
	private ProCategoryAttributeMapper proCategoryAttributeMapper;
	
	@Override
	public List<ProCategoryAttribute> getProCategoryAttributes(Integer proId) {
		if(proId!=null){
			return proCategoryAttributeMapper.selectProCategoryBycateId(proId);
		}else{
			return null;
		}
	
	}
	
	@Override
	public ProCategoryAttribute getProCategoryAttributeById(int id) {
		ProCategoryAttribute pcategory = new ProCategoryAttribute();
		pcategory.setId(id);
		pcategory.setRemoved(0);
		return proCategoryAttributeMapper.selectOne(pcategory);
	}

	@Override
	public void saveOrUpdate(ProCategoryAttribute prcate) {
		if(prcate.getId()!=null){
			proCategoryAttributeMapper.updateByPrimaryKeySelective(prcate);
		}else{
			proCategoryAttributeMapper.insertSelective(prcate);
		}
	}

	@Override
	public List<ProCategoryAttribute> getProCategoryAttributeByCategoryId(int categoryId) {
		return proCategoryAttributeMapper.getProCategoryAttributeByCategoryId(categoryId);
	}

	@Override
	public void deleteAttribute(ProCategoryAttribute oldatt) {
		oldatt.setRemoved(1);
		proCategoryAttributeMapper.updateByPrimaryKeySelective(oldatt);
	}
	

}
